package ar.com.digitalbricks.core.impl;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.HashSet;

import org.springframework.beans.factory.annotation.Configurable;

import ar.com.digitalbricks.core.MenuItem;
import ar.com.digitalbricks.core.TipoMenuItem;
import ar.com.digitalbricks.core.dao.MenuItemDAO;
import ar.com.digitalbricks.fwk.impl.PersistentEntityAbstract;

/**
 * @author Abel Fillol
 *
 */
@Configurable("menuItem")
public class MenuItemImpl extends PersistentEntityAbstract implements MenuItem {
	private Collection<MenuItem> componentes;
	private BigDecimal precio;
	private TipoMenuItem tipoMenuItem;
	private MenuItemDAO menuItemDAO;

	@Override
	public Collection<MenuItem> getComponentes() {
		return this.componentes;
	}

	@Override
	public BigDecimal getPrecio() {
		return this.precio;
	}
	
	@Override
	public TipoMenuItem getTipoMenuItem() {
		return this.tipoMenuItem;
	}

	@Override
	public void setTipoMenuItem(TipoMenuItem tipoMenuItem) {
		this.tipoMenuItem = tipoMenuItem;
	}

	public void setComponentes(Collection<MenuItem> componentes) {
		this.componentes = componentes;
	}

	@Override
	public void setPrecio(BigDecimal precio) {
		this.precio = precio;
	}

	@Override
	public void addComponente(MenuItem menuItem) {
		if (this.componentes == null){
			this.componentes = new HashSet<MenuItem>();
		}
		this.componentes.add(menuItem);
	}

	@Override
	public void delete() {
		this.getMenuItemDAO().delete(this);
	}

	@Override
	public void save() {
		this.getMenuItemDAO().save(this);
	}

	public MenuItemDAO getMenuItemDAO() {
		return this.menuItemDAO;
	}

	public void setMenuItemDAO(MenuItemDAO menuItemDAO) {
		this.menuItemDAO = menuItemDAO;
	}
	
	
}